package com.devunion.reader.client.panel;

import com.extjs.gxt.ui.client.Events;
import com.extjs.gxt.ui.client.Style;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.event.TabPanelEvent;
import com.extjs.gxt.ui.client.widget.TabItem;
import com.extjs.gxt.ui.client.widget.TabPanel;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;

/**
 * @author Timoshenko Alexander 04.07.2009 : 18:57:44
 */
public class AdvancedWestPanel extends TabPanel {
    private TreeProjectPanel projectPanel = new TreeProjectPanel();
    
    public AdvancedWestPanel() {
        setTabPosition(TabPosition.BOTTOM);

        projectPanel.initialize();

        final TabItem projectTabItem = new TabItem("Projects");
        projectTabItem.setLayout(new FitLayout());
        projectTabItem.setScrollMode(Style.Scroll.AUTOY);
        projectTabItem.add(projectPanel);
        add(projectTabItem);

        addListener(Events.Select, new Listener<TabPanelEvent>() {
            public void handleEvent(TabPanelEvent tabPanelEvent) {
                if (tabPanelEvent.item == projectTabItem) {
                    projectPanel.refresh();
                }
            }
        });
    }

    public TreeProjectPanel getProjectPanel() {
        return projectPanel;
    }
}
